import java.util.Arrays;

public class Question {
    //看一个数组是否有连续的三个奇数
    public static boolean ContiOdd(int[] array){
        int count = 0;
        for (int i = 0; i < array.length; i++) {
            if(array[i] % 2 != 0){
                count++;
                if(count==3){
                    return true;
                }
            }else{
                count = 0;
            }
        }
        return false;
    }

    //返回一个数组中出现次数最多的数
    //1.直接排序 - 投机取巧
    public static int element(int[] array){
        Arrays.sort(array);
        return array[array.length/2];
    }
    //2.投票法
    public static int element2(int[] arr){
        int ret = arr[0], count = 0;
        for (int i = 0; i < arr.length; i++) {
            if(arr[i] == ret){
                count++;
            }else {
                count--;
            }
            if(count == 0){
                ret = arr[i+1];
            }
        }
        return ret;
    }


    //找出数组中两个数相加等于指定值target，一组即可
    public static int[] func(int[] array,int targets){
        int[] ret = new int[2];
        for (int i = 0; i < array.length; i++) {
            for (int j = i+1; j < array.length; j++) {
                if(array[i] + array[j] == targets){
                    ret[0] = array[i];
                    ret[1] = array[j];
                    return ret;
                }
            }
        }
        return ret;
    }
    //找出一个数组中只出现一次的数
    public static int func2(int []array){
//        int ret = 0;
//        for (int i = 0; i < array.length; i++) {
//            ret = ret ^ array[i]
//        }
        int ret = array[0];
        for (int i = 1; i < array.length; i++) {
            ret = ret ^ array[i];
        }
        return ret;
    }
    public static void main(String[] args) {
        int[] arr = {1,1,1,1,3,3,4,1};
        int[] arr2 = {1,2,3,1,5};
        System.out.println(ContiOdd(arr2));
    }
}
